package com.youyunsoft.commons.rx.Interceptor;

import android.text.TextUtils;

import com.blankj.utilcode.util.SPUtils;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Response;

public class CookieSaveInterceptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {

        Response originalResponse = chain.proceed(chain.request());

        String headers = originalResponse.header("Set-Cookie");

        if (!TextUtils.isEmpty(headers)) {

            SPUtils.getInstance().put("LOGIN_COOKIE", headers);

//            LogUtil.e("cookie write:"+headers);

        }
        return originalResponse;

    }
}
